/**
 * 
 * 法师基类
 * @author 
 *
 */
class MagicWizardBase extends egret.MovieClip {
    /**状态标签*/
    protected stateLabel: string;
    /**结束标签*/
    protected endLabel: string;
    /**等待标签*/
    protected idleLabel: string;

    /**view MovieClip*/
    public view: egret.MovieClip;

    /**当前状态*/
    protected curState: stateType;
    /**FSM*/
    protected fsm: StateMachine;

    public constructor() {
        super();
    }

    public onEnterFrame(advancedTime: number) {
        this.checkLastEnd(this.stateLabel);
    }
        	
    /**发射 参数：方向*/
    public fire(direct: string) {
        if(direct == "down") {
            this.stateLabel = "shoot_down";
            this.idleLabel = "idleDown";
        } else if(direct == "up") {
            this.stateLabel = "shoot_up";
            this.idleLabel = "idleUp";
        }
        this.gotoAndPlay(this.stateLabel);
    }
    
    /**循环播放检查*/
    private checkLast(str: string) {
        if(!this.view.isPlaying) {
            this.view.gotoAndPlay(str);
        }
    }
                
    /**播放结束检查*/
    private checkLastEnd(str: string) {
        if(!this.view.isPlaying) {
            this.view.stop();
            if(this.curState == stateType.fightState) {
                this.fsm.changeState(stateType.fightEndState);
            } else if(this.curState == stateType.deadState) {
                this.fsm.changeState(stateType.deadEndState);
            }
        }
    }

}
